package leecode;

/**
 * @Classname
 * @Description TODO
 * @Date 2021/7/23 22:21
 * @Created by Alberthch
 * 题目：检查是否区域内所有整数都被覆盖
 */
class Solution_1893 {
    public static boolean isCovered(int[][] ranges, int left, int right) {
        // 外层循环对所有数字进行判断
        for (int i = left; i <= right ; i++) {
            // 内层循环判断该数字是否被覆盖,被覆盖就要弹出了
            for (int j = 0; j < ranges.length; j++) {
                // 被覆盖就终止循环
                if (i >= ranges[j][0] && i <= ranges[j][1]) {
                    break;
                }

                // 遍历到最后还被覆盖，找不到了
                if (j == ranges.length-1) {
                    return false;
                }
            }
        }

        return true;
    }

    public static void main(String[] args) {
        int[][] a = new int[][]{{1,2},{3,4},{5,6}};
        int l = 2;
        int r = 5;
        System.out.println(isCovered(a,l,r));
    }
}
